﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ClientWPF.localhost;

namespace ClientWPF
{
    public partial class DeleteProductForm : Window
    {
        Service1 service = new Service1();
        AuthentificationCredentials authentification = new AuthentificationCredentials();

        public DeleteProductForm()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
        }

        private void DeleteProductButton_Click(object sender, RoutedEventArgs e)
        {
            authentification.Privileges = "admin";
            service.AuthentificationCredentialsValue = authentification;

            Product product = new Product();
            product.Name = NameBox.Text;

            if (service.CheckProductExist(product))
            {
                service.DeleteProduct(product);
                MessageBox.Show("Product " + product.Name + " deleted successfully!");
                Close();
            }
            else MessageBox.Show("Product " + product.Name + "don't exist!");
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
